package lcr;

import java.util.ArrayList;
import java.util.Deque;
import java.util.LinkedList;

public class Test0045 {
}

class Solution0045_1 {
    public int findBottomLeftValue(TreeNode root) {
        Deque<TreeNode> deque = new LinkedList<>();

        int ans = 0;
        deque.offer(root);
        while (!deque.isEmpty()){
            ans= deque.peek().val;
            int size = deque.size();

            for (int i = 0; i < size; i++) {
                TreeNode poll = deque.poll();
                if (poll.left != null) deque.offer(poll.left);
                if (poll.right != null) deque.offer(poll.right);
            }
        }
        return ans;
    }
}